/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Common;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

/**
 *
 * @author THIAGO
 */
public class BasePage {

    public void ShowErrorMesage(HttpServletRequest request, HttpServletResponse response, String erro, String page) throws ServletException {
        request.setAttribute("mensagem", erro);
        RequestDispatcher view = request.getRequestDispatcher(page);  // Retorna a mesma página que o chamou.  
        try {
            view.forward(request, response);
        } catch (IOException ex) {
            Logger.getLogger(BasePage.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void ShowAlertErrorMesage(String erro){
        try {
            JOptionPane.showMessageDialog(null, erro);
        } catch (Exception ex) {
            Logger.getLogger(BasePage.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
